class Namespace(object):

    '''
    Namespace, which works to contian names ,_^

    NOTE : name should not countain '__' in the front
    '''

    def __init__(self,**kwargs):

        for key,value in kwargs.items():
            setattr(self,key,value)

    def __add__(self,other):
        import copy
        res=copy.copy(self)

        if isinstance(other,Namespace):

            for key in dir(other):
                if not key.startswith('__'):
                    setattr(res,key,getattr(other,key))

        elif type(other) is dict:

            for key,value in other.items():
                setattr(res,key,other)

        else :
            try :
                res=self+dict(other)
            except ValueError:
                return NotImplemented

        return res

    def __repr__(self):
        return repr(self.__dict__)
            
class Event(Namespace):

    '''
    Event, based on namespace, has a special attr called subject
    '''

    def __init__(self,subject,**kwargs):

        self.subject=subject

        Namespace.__init__(self,**kwargs)

